package com.wt.wechatTools.view_model;

import android.app.Application;
import androidx.annotation.NonNull;
import androidx.lifecycle.AndroidViewModel;
import androidx.lifecycle.LiveData;

import com.wt.wechatTools.room.WorkRepository;
import com.wt.wechatTools.room.entity.ContactsEntity;
import com.wt.wechatTools.room.entity.UserEntity;

import java.util.List;

public class ContactsViewModel extends AndroidViewModel {
    public static final String TAG = "ContactsViewModel";
    private WorkRepository workRepository;

    public ContactsViewModel(@NonNull Application application) {
        super(application);
        workRepository = new WorkRepository(application);
    }

    //    ----------------------------------------------------------UserEneity
    /**
     * 删除用户信息
     */
    public void deleteUserAll(){
        workRepository.deleteUserAll();
    }


    /**
     * 获取用户信息
     * @return
     */
    public LiveData<UserEntity> getUserLive(){
            return  workRepository.getUserLive();
    }



//    ----------------------------------------------------------ContactsEntity

    /**
     * 根据任务批次查询数据
     * @return
     */
    public List<ContactsEntity> getContactsByTastBatch(Integer tastBatch)
    {
        return workRepository.getContactsByTastBatch(tastBatch);
    }

    /**
     * 根据任务批次查询数据
     * @return
     */
    public LiveData<List<ContactsEntity>> getContactsByTastBatchLive(Integer tastBatch)
    {
        return workRepository.getContactsByTastBatchLive(tastBatch);
    }

    /**
     * 获取第一条 数据
     * @return
     */
    public ContactsEntity getFirst()
    {
        return workRepository.getFirst();
    }

    /**
     * 获取所有
     * @return
     */
    public LiveData<List<ContactsEntity>> getAllContactsLive() {
        return workRepository.getAllContactsLive();
    }

    /**
     * 获取所有名单数据
     * @return
     */
    public List<ContactsEntity> getAllContacts() {
        return workRepository.getAllContacts();
    }

    /**
     * 获取不包含未使用状态的名单数据
     * @return
     */
    public List<ContactsEntity> getContacts() {
        return workRepository.getContacts();
    }


    /**
     * 根据状态查询手机号
     * @param state
     * @return
     */
    public LiveData<List<ContactsEntity>> getContactsByStateLife(Integer state)
    {
        return workRepository.getContactsByStateLife(state);
    }

    /**
     * 根据状态查询手机号
     * @param state
     * @return
     */
    public List<ContactsEntity> getContactsByState(Integer state)
    {
        return workRepository.getContactsByState(state);
    }

    /**
     * 插入
     * @param contactsEntities
     */
    public void insertList(List<ContactsEntity> contactsEntities) {
        workRepository.insertList(contactsEntities);
    }

    /**
     * 更新
      * @param contactsEntities
     */
    public void update(ContactsEntity... contactsEntities) {
        workRepository.updateContact(contactsEntities);
    }

    /**
     * 更新 ContactsEntity
     * @param contactsEntityList
     */
    public void updateContactList(List<ContactsEntity> contactsEntityList) {
        workRepository.updateContactList(contactsEntityList);
    }

    /**
     * 插入 ContactsEntity
     * @param contactsEntities
     */
    public void insert(ContactsEntity... contactsEntities) {
        workRepository.insert(contactsEntities);
    }

    /**
     * 根据手机号查询
     * @param cellPhone
     * @return
     */
    public ContactsEntity getContactsByCellPhone(String cellPhone)
    {
        return workRepository.getContactsByCellPhone(cellPhone);
    }

    /**
     * 查询 状态 2和3（已执行和无法查找）
     * @return
     */
    public LiveData<List<ContactsEntity>> getContactsBy2and3Life()
    {
        return workRepository.getContactsBy2and3Life();
    }

}